package com.bw.jetpacktest.databinding;

import android.os.Bundle;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.databinding.DataBindingUtil;

import com.bw.jetpacktest.R;
import com.bw.jetpacktest.databinding.ActivityBasicBinding;

/**
 * databing基本使用,将BasicActivity中String字符串设置到xml下得textview中
 * ActivityBasicBinding->databind在xml中配置绑定完成，构建项目时，databinding自动创建与xml名称
 * 相同得一个Java类->将xml中声明要接受得数据传递
 * */
public class BasicActivity extends AppCompatActivity {
    private  ActivityBasicBinding binding;
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        binding = DataBindingUtil.setContentView(this, R.layout.activity_basic);
        binding.setStr("haha");
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        binding.unbind();
    }
}
